
# 转换为其他python对象

import torch

Y = torch.tensor([[2.0, 1, 4, 3], [1, 2, 3, 4], [4, 3, 2, 1]])
X = torch.arange(12, dtype=torch.float).reshape(3, 4)

A = X.numpy()
B= torch.tensor(A)
print(type(A), type(B))


a = torch.tensor([3.5])
print(a, a.item(), float(a), int(a))